<?php

namespace App\Http\Model;

use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Crypt;

class ShopAccount extends Model
{
    protected $table = 'shop_account';		//related table name
    protected $guarded = [];

    //访问器：获取用户的密码自动转换解密密码
    public function getPswAttribute($value)
    {
        try {
            return Crypt::decrypt($value);
        } catch (DecryptException $e) {
            throw $e;
        }
    }


    //修改器：给用户的密码加密
    public function setPswAttribute($value)
    {
        $this->attributes['psw']=bcrypt($value);
    }
    

}
